package zozopo.background.operator;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import zozopo.background.operator.operations.OperatorOS;
import zozopo.background.operator.operations.OperatorTB;
import zozopo.user.operations.UserOS;
import zozopo.user.operations.UserTB;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class ModifyLimitedflagAction extends ActionSupport implements Action,SessionAware{
	//传入参数
	private String limitjson ;
	private String email;
	
	private Map<Object, Object> session;
	public void setSession(Map arg0) {
		// TODO Auto-generated method stub
		session = arg0;
	}
	public String execute(){
		OperatorOS operatorOS = new OperatorOS();
		
		OperatorTB operator = operatorOS.getInfoByEmail(email);
		
		String limitFlag = operatorOS.jsonLimitFlagToUserLimitFlag(limitjson,operator.getLimitedflag_operator());
		
		if(!operatorOS.updateLimitByEmail(email, limitFlag)){
			return ERROR;
		}
		

		operatorOS.releaseConnection();
		
		return SUCCESS;
	}
	
	public void validate() {
		//权限处理
	
		OperatorTB operator = (OperatorTB)session.get("operatorInfo"); 
	
		if(operator == null){
			addFieldError("errormessage",getText("operator.timeoutornotlogin"));
			return ; 
		} 
		if(!OperatorOS.operatorFlagLeve(operator, 17, 1)){
			
			addFieldError("errormessage","权限不足");
			return ; 
		}//*/
		
	}
	
	public String getLimitjson() {
		return limitjson;
	}
	public void setLimitjson(String limitjson) {
		this.limitjson = limitjson;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	
}
